import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xinxuan/controllers/common_page_controller.dart';
import 'package:xinxuan/router/app_routers.dart';

class RouteAuthMiddleware extends GetMiddleware {

  final CommonPageController commonPageController = Get.find();

  @override
  RouteSettings? redirect(String? route) {
    if (!commonPageController.isAuthenticated.value) {
      return RouteSettings(name: '${AppRouters.COMMON_PAGE}${AppRouters.LOGIN_PAGE}');
    } else {
      return super.redirect(route);
    }
  }

}